//
//  BESideMenuHeader.swift
//  BEGlobalOiler
//
//  Created by KKING on 16/8/30.
//  Copyright © 2016年 Bullseye Energy pte ltd. All rights reserved.
//

import UIKit

class BESideMenuHeader: UIView {
    
    @IBOutlet weak var userNameTF: UILabel!
    @IBOutlet weak var iconImgView: UIImageView!
    
    class func header()->UIView {
        return Bundle.main.loadNibNamed("BESideMenuHeader", owner: nil, options: nil)!.last as! UIView
    }
    
    
    
    override func awakeFromNib() {
        super.awakeFromNib()
        
        userNameTF.text = BEAccountModel.shareAccount()?.username ?? "Please Login"
        
        guard let urlString = BEAccountModel.shareAccount()?.photo else {
            return
        }
        let url = URL(string: urlString)
        iconImgView.kf.setImage(with: url, placeholder: #imageLiteral(resourceName: "avatar_default_big"), options: [], progressBlock: nil, completionHandler: nil)
    }
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        _ = isLogin()
    }

}
